home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / grafica / amhelios / win_text.h < prev    next >
C/C++ Source or Header  |  1999-01-01  |  2KB  |  81 lines

  1. ////////////////////////////////////////////////////////////
  2. //
  3. //  WIN_TEXT.H - MS-Windows Text File Class Include File
  4. //
  5. //  Version:    1.03A
  6. //
  7. //  History:    94/08/23 - Version 1.00A release.
  8. //              94/12/16 - Version 1.01A release.
  9. //              95/02/05 - Version 1.02A release.
  10. //              95/07/21 - Version 1.02B release.
  11. //              96/02/14 - Version 1.02C release.
  12. //              96/04/01 - Version 1.03A release.
  13. //
  14. //  Compilers:  Microsoft Visual C/C++ Professional V1.5
  15. //              Borland C++ Version 4.5
  16. //
  17. //  Author:     Ian Ashdown, P.Eng.
  18. //              byHeart Software Limited
  19. //              620 Ballantree Road
  20. //              West Vancouver, B.C.
  21. //              Canada V7S 1W3
  22. //              Tel. (604) 922-6148
  23. //              Fax. (604) 987-7621
  24. //
  25. //  Copyright 1994-1996 byHeart Software Limited
  26. //
  27. //  The following source code has been derived from:
  28. //
  29. //    Ashdown, I. 1994. Radiosity: A Programmer's
  30. //    Perspective. New York, NY: John Wiley & Sons.
  31. //
  32. //  It may be freely copied, redistributed, and/or modified
  33. //  for personal use ONLY, as long as the copyright notice
  34. //  is included with all source code files.
  35. //
  36. ////////////////////////////////////////////////////////////
  37.  
  38. #ifndef _WIN_TEXT_H
  39. #define _WIN_TEXT_H
  40.  
  41. #include <string.h>
  42. #include "general.h"
  43.  
  44. // NOTE: Requires LARGE memory model for Win16
  45.  
  46. class WinText   // MS-Windows text file
  47. {
  48.   private:
  49.     FILE *pfile;        // File pointer
  50.  
  51.   public:
  52.  
  53.     // Close file
  54.     void Close() { (void) fclose(pfile); }
  55.  
  56.     // Read next line from file
  57.     void GetLine( char *pline, int max )
  58.     {
  59.       char *pstr;       // String pointer
  60.  
  61.       if ((pstr = fgets(pline, max, pfile)) != NULL)
  62.         pstr = strchr(pline, '\n');
  63.  
  64.       if (pstr == NULL)
  65.         pstr = pline;
  66.  
  67.       *pstr = '\0';     // Strip off newline
  68.     }
  69.  
  70.     BOOL Open( char *fname )    // Open text file
  71.     {
  72.       if ((pfile = fopen(fname, "r")) != NULL)
  73.         return TRUE;
  74.       else
  75.         return FALSE;
  76.     }
  77. };
  78.  
  79. #endif
  80.  
  81.